package com.macro.mall.portal.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.macro.mall.mapper.CmsFeedbackCategoryMapper;
import com.macro.mall.mapper.CmsFeedbackMapper;
import com.macro.mall.mapper.PmsCommentMapper;
import com.macro.mall.model.*;
import com.macro.mall.portal.domain.AddPmsProductComment;
import com.macro.mall.portal.domain.PmsProductCommentRes;
import com.macro.mall.portal.service.CommentService;
import com.macro.mall.portal.service.FeedBackService;
import com.macro.mall.portal.service.UmsMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.security.auth.login.LoginContext;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;


@Service
public class FeedBackImpl implements FeedBackService {

    @Autowired
    private CmsFeedbackMapper cmsFeedbackMapper;
    @Autowired
    private CmsFeedbackCategoryMapper cmsFeedbackCategoryMapper;
    @Autowired
    private UmsMemberService memberService;

    @Override
    public List<CmsFeedbackCategory> selFeedBackList() {
        //查询反馈分类列表

        CmsFeedbackCategoryExample cmsFeedbackCategoryExample = new CmsFeedbackCategoryExample();


        return cmsFeedbackCategoryMapper.selectByExample(cmsFeedbackCategoryExample);
    }


    @Override
    public void addFeedBackList(CmsFeedback cmsFeedback) {
        if (cmsFeedback == null){
            return;
        }
        //反馈内容小于500子
        if (cmsFeedback.getContent().length() > 500){
            return;
        }
        UmsMember currentMember = memberService.getCurrentMember();
        cmsFeedback.setMemberId(currentMember.getId());
        cmsFeedback.setCreateTime(new Date());
//        cmsFeedbackMapper.(cmsFeedback);
    }
}
